﻿<UserControl x:Class="PocketBook.Views.BookEditorView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Themes/generic.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <Style x:Key="SiteLabel" TargetType="TextBlock">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="FontSize" Value="20" />
            <Setter Property="Foreground" Value="#40808080" />
        </Style>
        </ResourceDictionary>
    </UserControl.Resources>
    <DockPanel Margin="6" x:Name="LayoutRoot">
        <!--<Button DockPanel.Dock="Bottom" Content="_Print" x:Name="Print" />-->

        <ListBox x:Name="Layout" VerticalAlignment="Top" SelectedItem="{Binding SelectedItem}" BorderThickness="0">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid Columns="2" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border Style="{StaticResource PageSite}" Tag="{Binding DataContext, ElementName=LayoutRoot}" >
                        <Border.ContextMenu>
                            <ContextMenu cal:Action.TargetWithoutContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
                                <MenuItem Header="Move..." cal:Message.Attach="MoveDesign($dataContext)" />
                            </ContextMenu>
                        </Border.ContextMenu>

                        <Grid>
                            <Viewbox Stretch="Uniform" IsHitTestVisible="false">
                                <ContentControl cal:View.Model="{Binding Design}" Width="{Binding Design.Size.Width}" Height="{Binding Design.Size.Height}" />
                            </Viewbox>
                            <TextBlock Style="{StaticResource SiteLabel}" Text="{Binding DisplayName}"/>
                        </Grid>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </DockPanel>
</UserControl>
